<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jspf/must/basePath.jspf" %>
<!--后台UI组件Start-->
<%@include file="/WEB-INF/jspf/zj/ligerui/LigerUI.jspf" %>
<%@include file="/WEB-INF/jspf/zj/ligerui/LigerUI_form.jspf" %>
<!--后台UI组件End-->

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <script src="dc_manager/base/scheme/combo/fl/lookup/comboflLookUp.js" type="text/javascript"></script>
        <script src="dc_manager/base/scheme/combo/js/comboxB.js" type="text/javascript"></script>
        <script type="text/javascript">
            var GRID;
            $(function() {
                f_dcBaseCombofl("flid2", "flid", 200, 400, 100);
                GRID = $("#divID_GRID").ligerGrid({
                    columns: [
                        {display: '食物ID', name: 'food_id', hide: true}
                        , {display: '名称', name: 'food_name', width: 130, align: 'left'}
                        , {display: '编码', name: 'food_code', width: 110, align: 'left', editor: {type: 'text'}}
                        , {display: '单价', name: 'food_price', width: 60, align: 'left', editor: {type: 'text'}}//带出食物档案的价格。可以再次调整
                        , {display: '数量', name: 'food_number', width: 60, align: 'left', type: 'float', editor: {type: 'float'}}
                        , {display: '金额', name: 'food_priceSum', width: 90, align: 'left', type: 'float'}//单价*数量
                        , {display: '单位ID', name: 'unit_id', hide: true}
                        , {display: '单位', name: 'unit_name', width: 40, align: 'left'}
                    ]
                    , enabledEdit: true
//                    , onBeforeEdit: f_edit1
                    , onAfterEdit: f_edit2
                    , usePager: false
                    , url: ''
                    , width: '550px'
                    , height: '97%'
                });
                $("#toptoolbar").ligerToolBar({items: [
//                        {text: '保存', click: save}
                        {line: true}
                        , {text: '增加', click: add}
                        , {line: true}
                        , {text: '移除', click: dell}
                        , {line: true}
//                        , {text: '复制BOM', click: copyBOM}
                    ]});
                $.metadata.setType("attr", "validate");
                var v = $("#Combo_formID").validate({
                    debug: false,
                    errorPlacement: function(lable, element) {
                        if (element.hasClass("l-textarea")) {
                            element.addClass("l-textarea-invalid");
                        }
                        else if (element.hasClass("l-text-field")) {
                            element.parent().addClass("l-text-invalid");
                        }
                    },
                    success: function(lable) {
                        var element = $("#" + lable.attr("for"));
                        if (element.hasClass("l-textarea")) {
                            element.removeClass("l-textarea-invalid");
                        }
                        else if (element.hasClass("l-text-field")) {
                            element.parent().removeClass("l-text-invalid");
                        }
                    },
                    submitHandler: function() {
                        var f_NV = $("#Combo_divID :input[name,value]");
                        var data = {};
                        for (var i = 0; i < f_NV.length; i++) {
                            if (null != f_NV[i].name && f_NV[i].name.length > 0) {
                                data[f_NV[i].name] = f_NV[i].value;
                            }
                        }
                        data["list"]=JSON2.stringify(GRID.getData());
//                        alert(JSON2.stringify(data));
                        post_json("weixinkeji/dev/dc/base/scheme/combo/combo/adu/add.imy",data,400,200);
                        return false;
                    }
                });
                var OBJ_FORM = $("#Combo_formID").ligerForm();
                //               function f_BMLookUP() {
//                    OBJ_FORM.hideFieldError("");
//                }
            });
            function add() {
                GRID.endEdit();
                GRID.addRow({food_number: 1});
            }
            function dell() {
                var row = GRID.getSelectedRow();
                if (null != row) {
                    GRID.endEdit();
                    GRID.deleteRow(row);
                }
            }
            function f_edit2(e) {
                f_add_comboxb(e.column.name, e.value);
            }
        </script>
        <style type="text/css">
            body{ font-size:12px;}
            .l-table-edit {}
            .l-table-edit-td{ padding:4px;}
            .l-button-submit,.l-button-test{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
            .l-verify-tip{ left:230px; top:120px;}
        </style>
    </head>
    <body style="padding:10px">
        <div>
            <div id="Combo_divID" style="float:left">
                <form name="form" method="post"  id="Combo_formID">
                    <table cellpadding="0" cellspacing="0" class="l-table-edit" >
                        <tr>
                            <td align="right" class="l-table-edit-td">分类:</td>
                            <td align="left" class="l-table-edit-td" style="width:160px">
                                <input type="text" name="flid" id="flid2" validate="{required:true,minlength:1}" maxlength="26" ltype="text"/>
                            </td><td align="left"></td>
                        </tr>
                        <tr>
                            <td align="right" class="l-table-edit-td">编码:</td>
                            <td align="left" class="l-table-edit-td" style="width:160px">
                                <input type="text" name="combo_code" id="combo_code" validate="{required:true,minlength:1}" maxlength="26" ltype="text"/>
                            </td><td align="left"></td>
                        </tr>
                        <tr>
                            <td align="right" class="l-table-edit-td">名称:</td>
                            <td align="left" class="l-table-edit-td" style="width:160px">
                                <input type="text" name="combo_name" id="combo_name" validate="{required:true,minlength:1}" maxlength="26" ltype="text"/>
                            </td><td align="left"></td>
                        </tr>
                        <tr>
                            <td align="right" class="l-table-edit-td">启用:</td>
                            <td align="left" class="l-table-edit-td" style="width:160px">
                                <select name="combo_style" id="combo_style">
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                </select>
                            </td><td align="left"></td>
                        </tr>
                        <tr>
                            <td align="right" class="l-table-edit-td">价格:</td>
                            <td align="left" class="l-table-edit-td" style="width:160px">
                                <input type="text" name="combo_price" id="combo_price" validate="{required:true,minlength:1}" maxlength="11" ltype="text"/>
                            </td><td align="left"></td>
                        </tr>
                        <tr>
                            <td align="right" class="l-table-edit-td">每单限购:</td>
                            <td align="left" class="l-table-edit-td" style="width:160px">
                                <input type="text" name="combo_number" id="combo_number" validate="{required:true,minlength:1}" maxlength="3" ltype="text"/>
                            </td><td align="left"></td>
                        </tr>
                        <tr>
                            <td align="right" class="l-table-edit-td">备注:</td>
                            <td align="left" class="l-table-edit-td" style="width:160px">
                                <input type="text" name="combo_info" id="combo_info" validate="{required:true,minlength:1}" maxlength="26" ltype="text"/>
                            </td><td align="left"></td>
                        </tr>
                        <!--                        <tr>
                                                    <td align="right" class="l-table-edit-td">清单金额:</td>
                                                    <td align="left" class="l-table-edit-td" style="width:160px">
                                                        <input type="text" name="combo_listPriceSum" id="combo_listPriceSum" validate="{required:true,minlength:1}" maxlength="0" ltype="text"/>
                                                    </td><td align="left"></td>
                                                </tr>-->
                        <tr style=" height: 100px;">
                            <td></td>
                            <td>
                                <input type="submit" value="提交" id="Button1" class="l-button l-button-submit" /> 
                            </td><td></td>
                        </tr>
                    </table>
                    <br />
                </form>
            </div>
            <div  style="float:left">
                <div id="toptoolbar"></div> 
                <div id="divID_GRID" style="margin:0; padding:0"></div>
            </div>
        </div>
    </body>
</html>
